package javabase.schoolwork.day6_6;

import org.junit.Test;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

/**
 * @author fance
 * @date 18-6-6 下午3:35
 */
public class EnumSum {
    public void getContent() {
        Color color = Color.GREEN;
        System.out.println(color);
    }
    public void printEnum() {
        for (Color color : Color.values()) {
            System.out.println(color.ordinal() + " " + color.name() + " " + color.getName());
        }
        // switch

        Color color = Enum.valueOf(Color.class,"BLUE");
        color.setName("1");
        color.setName("2");
        System.out.println(color.getName());
    }

    public void compareEnum(){
        Set<Color> colorSet = new TreeSet<>();
        colorSet.add(Color.GREEN);
        colorSet.add(Color.BLUE);
        colorSet.add(Color.RED);

        for (Color color : colorSet) {
            System.out.println(color.getColor());
        }

        Iterator<Color> iterator = colorSet.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next().fun() + " ");
        }
    }
    @Test
    public void test() {
       /* getContent();
        printEnum();*/

        compareEnum();
    }
}
